package 泛型;

import java.lang.reflect.*;
import java.util.List;


public class ReturnTypeClass<T> {

    private List<T> arrays;

    private T[] arr;

    private T t;

    private List<T> getList() {
        return arrays;
    }


    private T get() {
        return t;
    }

    private T[] getArr() {
        return arr;
    }


    public static void main(String[] args) {

        //获取所有的方法
        Method[] declaredMethods = ReturnTypeClass.class.getDeclaredMethods();

        for (Method declaredMethod : declaredMethods) {
            //破坏私有性
            declaredMethod.setAccessible(true);
            //获取方法的返回值
            Type genericReturnType = declaredMethod.getGenericReturnType();

            System.out.println("方法名称 : " + declaredMethod.getName() + "放回值类型是否是TypeVariable类型  :  " + (genericReturnType instanceof TypeVariable));
            System.out.println("方法名称 : " + declaredMethod.getName() + "放回值类型是否是ParameterizedType类型  :  " + (genericReturnType instanceof ParameterizedType));
            System.out.println("方法名称 : " + declaredMethod.getName() + "放回值类型是否是GenericArrayType类型  :  " + (genericReturnType instanceof GenericArrayType));
        }
    }

}

